<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.CSACOrderWorkshop;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.CSACOrderWorkshop">
		<cfargument name="CSAC_Order_Workshop_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.CSAC_Order_Workshop_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new CSACOrderWorkshop();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				local.loadArgs.Deleted = 0;
				return load(argumentCollection = local.loadArgs);
			} else {
				return new CSACOrderWorkshop();
			}
		</cfscript>
	</cffunction>

	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.CSACOrderWorkshop" hint="Overwrites obj properties with provided arguments and returns updated obj">
		<cfargument name="obj" type="assets.calgrants.com.bo.CSACOrderWorkshop" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.CSAC_Order_Workshop_ID")) {
				local.obj.setCSAC_Order_Workshop_ID(arguments.CSAC_Order_Workshop_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.CSAC_Order_ID")) {
				local.obj.setCSAC_Order_ID(arguments.CSAC_Order_ID); 
			}
			if (IsDefined("arguments.Workshop_ID")) {
				local.obj.setWorkshop_ID(arguments.Workshop_ID); 
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}	
			return local.obj;
		</cfscript>
	</cffunction>
	
	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="CSAC_Order_Workshop_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="CSAC_Order_ID" required="false" default="" />
		<cfargument name="Workshop_ID" required="false" default="" />	
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="programYears" required="false" default="" />
		<cfargument name="csacOrderIDs" required="false" default="" />
		<cfargument name="workshopIDs" required="false" default="" />
		<cfargument name="organizationIDs" required="false" default="" />
		
		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readCSACOrderWorkshop">
			<cfprocparam value="#arguments.CSAC_Order_Workshop_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CSAC_Order_Workshop_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.CSAC_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CSAC_Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Workshop_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Workshop_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.programYears#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.programYears)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.csacOrderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.csacOrderIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.workshopIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.workshopIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.organizationIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.organizationIDs)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="csacOrderWorkshop" required="true" type="assets.calgrants.com.bo.CSACOrderWorkshop" />
		<cfstoredproc datasource="#getDatasource()#" procedure="saveCSACOrderWorkshop">
			<cfprocparam value="#csacOrderWorkshop.getCSAC_Order_Workshop_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#csacOrderWorkshop.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#csacOrderWorkshop.getCSAC_Order_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#csacOrderWorkshop.getWorkshop_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="CSAC_Order_Workshop_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyCSACOrderWorkshop">
			<cfprocparam value="#arguments.CSAC_Order_Workshop_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

